/**
 * WTF Engine
 * 
 * License... etc.
 **
 * Water Effects Shader
 **
 * Authors: Sean Micklethwaite
 */

#ifndef __fx_water_surfaceH__
#define __fx_water_surfaceH__

#include "terrain.h"
#include "physics.h"
#include "cubemap.h"

#define FX_WATER_SURFACE_THICKNESS	0.1

namespace WtfEngine {
	class WaterSurfaceRefractionShader: public GLSLProgram {
		CubeMap::tRef	mrCubeMap;
		int				mCubeMapLocation;
		int				mSurfaceLocation;

		public:
			WaterSurfaceRefractionShader(const CubeMap::tRef& rCubeMap);

			void GetLocations();
			void PassOther();

			void Deactivate();
	};

	class WaterSurface: public IDynamic, public Static {
		/// For cards which support pixel shader 3.0, this simulation
		/// will be run on the GPU (soon).
      FBOTexture::tRef	mrHeightMapA, mrHeightMapB;
      /// Buffers are shared with the height map renderer. Use pointers to references
      /// for fast swapping.
      NonCopyBuffer<tScalar>::tRef *	mprHeightMapA, * mprHeightMapB;
      tScalar *	mpVelocities;

      /// Height map dimensions
      iVector2D	mvDim;

		/// Direction & strength of water current
		fVector2D							mvCurrent;
		WtfGraphics::TerrainHeightMap::tRef	mrHeightMap;

		/// Handles events pertaining to the water surface
		void EventHandler();

		public:
			WaterSurface(const tCreationOptions& args, const tVector& vDim, const fVector2D& vCurrent);
			~WaterSurface();

			void Update();

			// TODO: correct size
			GC_AUTOSIZE(WaterSurface);
	};
};

#endif
